Music Object Extension - Snapshots
|
|
The Snapshots extension provides methods for easily capturing and restoring mix snapshots for RMF and MIDI files that are playing - something that can prove quite useful when creating certain kinds of remixing applications.
|
What's New in the Latest Version
|
There is a dedicated version history for this extension, where you will be able to find out about the new features and possible issues with the most recent version. The version history for this extension is independent of the version history for the core Music Object API.
To get the "music-object-x-snapshots.js" JavaScript file that implements this extension, simply right-click on this link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file as "music-object-x-snapshots.js" into an appropriate folder of the local copy of your Web site.
In case you have problems saving the file using the above link, the "music-object-x-snapshots.js" file can also be found inside the documentation's "javascript" folder, along with the "music-object.js" file.
In order to use this extension, the following JavaScript file(s) must first be sourced in...
- music-object.js (version 3.3.0 or higher)
For more information on using extensions, consult the section About Music Object Extensions.
| Name |
Short Description |
| Instance Methods |
| captureSnapshot |
Lets you capture a snapshot of the current playback state for an RMF or MIDI file. |
| getSnapshotFilter |
Returns a string value, representing the current filter settings being used for the specified snapshot. |
| isSnapshotDefined |
Returns a boolean value, indicating whether or not there exists a snapshot by the specified name. |
| recallSnapshot |
Lets you recall the specified snapshot, so that the Music Object instance is restored to the playback state captured by that snapshot. |
| removeSnapshot |
Lets you remove (clear) the snapshot of the specified name. |
| resetSnapshotFilter |
Lets you reset the filter settings for the specified snapshot, so that either all or none of the filter options are enabled. |
| setSnapshotFilter |
Lets you set the filter settings for the specified snapshot. |
| Static Properties |
| Music.defaultSnapshotFilter |
A string variable, specifying the default value that should be used for the SnapshotFilterSTR parameter, if this parameter is not specified when using the captureSnapshot and setSnapshotFilter instance methods. |
| Common Parameters |
| SnapshotFilterSTR |
A string, specifying the enabled state for the various available snapshot filter options. |
|
|
The captureSnapshot instance method lets you capture a snapshot of the current playback state for an RMF or MIDI file.

- When a value of null is specified for the SnapshotFilterSTR parameter and the snapshot is being created for the first time, then the value of the Music.defaultSnapshotFilter static property is used for this parameter. If a snapshot already exists with the name specified by the SnapshotNameSTR parameter and the value null is specified for the SnapshotFilterSTR parameter, then the snapshot's current filter settings will not be changed.

- captureSnapshot ( SnapshotNameSTR )
When no SnapshotFilterSTR parameter is specified and the snapshot is being created for the first time, then the value of the Music.defaultSnapshotFilter static property is used for this parameter. If a snapshot already exists with the name specified by the SnapshotNameSTR parameter and no SnapshotFilterSTR parameter is specified, then the snapshot's current filter settings will not be changed.
The getSnapshotFilter instance method returns a string value, representing the current filter settings being used for the specified snapshot.
|
getSnapshotFilter ( SnapshotNameSTR ) |
Filter settings can be easily copied from one snapshot to another using a combination of the getSnapshotFilter and setSnapshotFilter methods, as in the example...
myMusicObject.setSnapshotFilter (
'My Snapshot 2',
myMusicObject.getSnapshotFilter ('My Snapshot 1')
);
|
In this example, we are calling the setSnapshotFilter method in order to set the filter for the snapshot named "My Snapshot 2". For the SnapshotFilterSTR parameter of the setSnapshotFilter method we are passing the result of the expression myMusicObject.getSnapshotFilter ('My Snapshot 1'), which retrieves the filter from the snapshot named "My Snapshot 1". This has the effect of copying the filter for the snapshot "My Snapshot 1" to the snapshot "My Snapshot 2".

- When no snapshot exists with the name specified by the SnapshotNameSTR parameter, then this method will return an empty string.
- The filter settings for a snapshot can be set using the setSnapshotFilter instance method.
The isSnapshotDefined instance method returns a boolean value, indicating whether or not there exists a snapshot by the specified name.
|
isSnapshotDefined ( SnapshotNameSTR ) |
|
boolean |
The recallSnapshot instance method lets you recall the specified snapshot, so that the Music Object instance is restored to the playback state captured by that snapshot.

- When a value of null is specified for the SnapshotFilterSTR parameter, then the snapshot's current filter settings are used.

The removeSnapshot instance method lets you remove (clear) the snapshot of the specified name.
|
removeSnapshot ( SnapshotNameSTR ) |
Once a snapshot has been removed using this method, any attempt to recall it using the recallSnapshot instance method will fail and will simply be ignored.
The resetSnapshotFilter instance method lets you reset the filter settings for the specified snapshot, so that either all or none of the filter options are enabled.
|
resetSnapshotFilter ( SnapshotNameSTR , ResetStateSTR ) |
When a string value of "ON", "1", or "TRUE" is specified for the ResetStateSTR parameter, then the filter will be reset so that all filter options are enabled. And when a string value of "OFF", "0", or "FALSE" is specified for the ResetStateSTR parameter, then the filter will be reset so that all filter options are disabled.

The setSnapshotFilter instance method lets you set the filter settings for the specified snapshot

- When a value of null is specified for the SnapshotFilterSTR parameter, then the value of the Music.defaultSnapshotFilter static property is used for this parameter.


- The filter settings for a snapshot can be queried using the getSnapshotFilter instance method.
The Music.defaultSnapshotFilter static property is a string variable, specifying the default value that should be used for the SnapshotFilterSTR parameter, if this parameter is not specified when using the captureSnapshot and setSnapshotFilter instance methods.
The default value for the Music.defaultSnapshotFilter property is "CHANNELMUTE=ON CHANNELSOLO=ON CHANNELMODULATION=ON CHANNELVOLUME=ON CHANNELPAN=ON CHANNELEXPRESSION=ON CHANNELSUSTAIN=ON CHANNELREVERBTYPE=ON CHANNELREVERBLEVEL=ON CHANNELCHORUSLEVEL=ON POSITION=ON TEMPO=ON TRANSPOSE=ON VOLUME=ON".
| |
| CATEGORY |
Parameter |
| Type |
string |
| | |
|
The SnapshotFilterSTR parameter is a string, specifying the enabled state for the various available snapshot filter options.
The syntax of the SnapshotFilterSTR parameter is much like that of the EmbedLineSTR parameter that is used by the various embedding methods of the Music Object API, and consists of a series of name/value pairs seperated by whitespace. Each name/value pair has the syntax...
FilterOptionName=[ON|1|TRUE|OFF|0|FALSE]
The values "ON", "1", and "TRUE" all have the same meaning and indicate that the filter option will be enabled. Similarly, the values "OFF", "0", and "FALSE" all have the same meaning and indicate that the filter option will be disabled.
So, for example, the value "CHANNELPAN=ON TEMPO=OFF POSITION=FALSE TRANSPOSE=1" for the SnapshotFilterSTR parameter specifies that the filter options for channel pan and transposition are enabled, whereas the filter options for tempo and position are disabled.
For the SnapshotFilterSTR parameter, the following filter option names can be specified...
- CHANNELMUTE
lets you enable or disable the recall of channel mute settings.
- CHANNELSOLO
lets you enable or disable the recall of channel solo settings.
- CHANNELMODULATION
lets you enable or disable the recall of channel modulation settings (MIDI controller 1).
- CHANNELVOLUME
lets you enable or disable the recall of channel volume settings (MIDI controller 7).
- CHANNELPAN
lets you enable or disable the recall of channel pan settings (MIDI controller 10).
- CHANNELEXPRESSION
lets you enable or disable the recall of channel expression settings (MIDI controller 11).
- CHANNELSUSTAIN
lets you enable or disable the recall of channel sustain pedal settings (MIDI controller 64).
- CHANNELREVERBTYPE
lets you enable or disable the recall of channel reverb type settings (MIDI controller 90).
- CHANNELREVERBLEVEL
lets you enable or disable the recall of channel reverb level settings (MIDI controller 91).
- CHANNELCHORUSLEVEL
lets you enable or disable the recall of channel chorus level settings (MIDI controller 93).
- POSITION
lets you enable or disable the recall of song position.
- TEMPO
lets you enable or disable the recall of playback tempo.
- TRANSPOSE
lets you enable or disable the recall of pitch transposition.
- VOLUME
lets you enable or disable the recall of volume level.
